require("../util.js");
require("../component/components.js");
require("../../jsMt/util.js");
var userInfo=JSON.parse(sessionStorage.getItem("userInfo"));
if(!userInfo){
    location.href="/loginIndex"
}
console.log(userInfo)
var vm = new Vue({
    el:"#forward",
    data:{
        loadFlag:false,
        circleList:{}, //圈子列表
        postId:""  //帖子id
    },
    mounted:function(){
        this.searchObject = this.getQueryStringArgs();
        if(this.searchObject&&this.searchObject.postId){
            this.postId=this.searchObject&&this.searchObject.postId;
            //this.getPost();
        }
        this.getCircleList();
    },
    methods:{
        //后退
        getBack: function () {
            history.go(-1);
        },
        bgimg:function(url){
            url = url?url:"";
            return {
                "background-image":'url("'+url+'"),url("")'
            }
        },
        /*获取查询字符对象*/
        getQueryStringArgs: function () {
            //取得查询字符串并去掉开头的问号
            var qs = (location.search.length > 0 ? location.search.substring(1) : ""),
                args = {},
                items = qs.length ? qs.split("&") : [],
                item = null,
                name = null,
                value = null,
                len = items.length;
            for (var i = 0; i < len; i++) {
                item = items[i].split("=");
                name = item[0];
                value = item[1];
                if (name.length) {
                    args[name] = value;
                }
            }
            return args;
        },
        //圈子列表
        getCircleList:function(){
            var that=this;
            this.ajax({url:"/friend/getCircleList",data:{loginUid:userInfo.id||that.uid},dataType:"json",method:"post"},function(b){
                if(b.json.code==0&&b.json.data){
                    that.circleList=b.json.data;
                    // vm.getList(1);
                    //console.log(that.circleList)
                }else{
                    vm.$refs.prompt.toast("获取圈子列表失败！")
                }
            });
        },
        getNext:function(list){
            console.log(list)
            location.href="/friend/forwardResult?circleId="+list.circleId+"&postId="+this.postId+"&circleName="+encodeURI(list.circleName);
        }
    }
});